<?php
namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\web\Response;

/**
 * @author qingyu8@staff.weibo.com
 * @date 2018/01/11
 */
class WechatController extends Controller {

    public $enableCsrfValidation = false;

    public function actionIndex() {
        /* @var $app \EasyWeChat\OfficialAccount\Application */
        $app = Yii::$app->wechat->app;
        Yii::$app->response->format = Response::FORMAT_JSON;
        $buttons = [
            [
                "type" => "view",
                "name" => "船宿预订",
                "url"  => "http://m.cooldive.com.cn?utm_source=fuwuhaocaidan&hmsr=%E6%9C%8D%E5%8A%A1%E5%8F%B7%E8%8F%9C%E5%8D%95&hmpl=&hmcu=&hmkw=&hmci="
            ],
//            [
//                "name"       => "菜单",
//                "sub_button" => [
//                    [
//                        "type" => "view",
//                        "name" => "搜索",
//                        "url"  => "http://www.soso.com/"
//                    ],
//                    [
//                        "type" => "view",
//                        "name" => "视频",
//                        "url"  => "http://v.qq.com/"
//                    ],
//                    [
//                        "type" => "click",
//                        "name" => "赞一下我们",
//                        "key" => "V1001_GOOD"
//                    ],
//                ],
//            ],
        ];
        return $app->menu->create($buttons);
    }
}
